#! /usr/bin/env python
from sqlite3 import dbapi2 as sqlite

conn = sqlite.connect("lotto-hist")
curs = conn.cursor()

curs.execute("select * from history ")
rows = curs.fetchall()
for row in rows:
	print row
	date_old = row[0]
	month, day, year = date_old.split("/")
	date_new = year + "-" + month + "-" + day
	curs.execute("update history set date = ? where date = ?", [date_new, date_old])
	conn.commit()

curs.execute("select * from history")
rows = curs.fetchall()
for row in rows:
	print row

	
curs.execute("select * from history sort by date")
rows = curs.fetchall()
for row in rows:
	print row

	
